/**
 * class Player
 *   - the player's name, position and his treasure number
 */
public class Player {
	private String name; // the player's name
	private int x, y; // the position
	private int treasure; // the number of the player's treasures
	
	public Player(String name, int treasure, int x, int y){
		this.name = name;
		this.x = x;
		this.y = y;
		this.treasure = treasure;
	}
	
	public Player(String name){
		this.name = name;
		this.treasure = 0;
	}
	
	public String getName() {
		return name;
	}
	
	public int getX() {
		return x;
	}
	
	public void setX(int x) {
		this.x = x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setY(int y) {
		this.y = y;
	}
	
	public void goEast(int edge) {
		x = x + 1;
		x = (x == edge) ? edge-1 : x;
	}
	
	public void goWest() {
		x = x - 1;
		x = (x == -1) ? 0 : x;
	}
	
	public void goNorth() {
		y = y - 1;
		y = (y == -1) ? 0 : y;
	}
	
	public void goSouth(int edge) {
		y = y + 1;
		y = (y == edge) ? edge-1 : y;
	}
	
	public int getTreasure() {
		return treasure;
	}
	
	// add treasure and return current treasure
	public int addTreasure(int newTreasure) {
		treasure += newTreasure;
		return treasure;
	}
}
